package moodish.server;

/**
 * Class that is used to store user info
 * 
 * @author hmcgf, ljgds, dbipo
 */
import java.util.Collection;
import java.util.HashMap;

public class User
{
	private String					username;
	private String					currentMood	= "";
	private HashMap<String, User>	friends		= new HashMap<String, User>();
	/**
	 * Constructor
	 * 
	 * @param username
	 *            User's username
	 */
	public User(String username)
	{
		this.username = username;
	}
	/**
	 * Function that returns the user's name
	 * 
	 * @return String username
	 */
	public String getUsername()
	{
		return username;
	}

	/**
	 * Function used to unfriend a user, should return true if user that is
	 * being removed is on the list
	 * 
	 * @param username
	 *            to be unfriend
	 * @return boolean if it was able or not to unfriend
	 */
	public boolean unfriend(String username)
	{
		return friends.remove(username) != null;
	}
	/**
	 * Function used to friend a user, should return true if user that is being
	 * removed is on the list
	 * 
	 * @param user
	 *            to be friend
	 * @return boolean if it was able or not to create friendship
	 */
	public boolean friend(User user)
	{
		return friends.put(user.getUsername(), user) != null;
	}
	/**
	 * Function that returns a collection of this user's friends
	 * 
	 * @return Collection<User>
	 */
	public Collection<User> getFriends()
	{
		return friends.values();
	}
	/**
	 * Function used to evaluate if a give user is a friend of this user, will
	 * return true if it is, else false
	 * 
	 * @param usernameNewFriend
	 *            to see if is friend or not
	 * @return boolean true or false whether they are friends or not
	 */
	public boolean isFriend(String usernameNewFriend)
	{
		return friends.containsKey(usernameNewFriend);
	}
	/**
	 * Function used to set the mood of the user
	 * 
	 * @param newMood
	 *            the mood to be set
	 */
	public void setMood(String newMood)
	{
		this.currentMood = newMood;
	}
	/**
	 * Function used to get the mood of the user
	 * 
	 * @return String the user's mood
	 */
	public String getMood()
	{
		return currentMood;
	}
}
